package cn.tedu.nybikeT.util;

import org.gavaghan.geodesy.Ellipsoid;
import org.gavaghan.geodesy.GeodeticCalculator;
import org.gavaghan.geodesy.GlobalCoordinates;

/**
 * 地图相关工具类
 * @author william
 *
 */
public class MapUtils {
	
	/**
	 * 计算两对经纬度之间的实际距离
	 * @param longitudeFrom
	 * @param latitudeFrom
	 * @param longitudeTo
	 * @param latitudeTo
	 * @return
	 */
	 public static double getDistance(double longitudeFrom, double latitudeFrom, double longitudeTo, double latitudeTo) {
	        GlobalCoordinates source = new GlobalCoordinates(latitudeFrom, longitudeFrom);
	        GlobalCoordinates target = new GlobalCoordinates(latitudeTo, longitudeTo);
	
	        return new GeodeticCalculator().calculateGeodeticCurve(Ellipsoid.Sphere, source, target).getEllipsoidalDistance();
	    }
}
